package week9;

import com.sun.org.apache.bcel.internal.generic.NEW;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

/**
 * @author The setting sun
 * @version 1.0
 * @title: Work3
 * @description: TODO
 * @date 2021/11/4 14:14
 */
public class Work3 {
    public static void main(String[] args) {
        new MyFrame1().init();
    }
}

class MyFrame1 {
    JFrame frame;
    JLabel label;
    JPanel panel;

    public MyFrame1() {
        frame = new JFrame();
        panel = new JPanel();

        label = new JLabel("亚索");
    }

    public void init() {
        label.setFont(new Font("微软雅黑", Font.BOLD, 28));
        label.setForeground(Color.CYAN);

        panel.setSize(600, 600);
        panel.add(label, BorderLayout.CENTER);

        frame.add(panel);
        frame.setVisible(true);
        frame.setSize(600, 600);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        String s1 = "且随疾风前行，身后亦需要留心";
        String s2 = "明日安在，无人能允";
        String s3 = "吾虽浪迹天涯，却未迷失本心";
        String s4 = "人们一直在往我的剑上撞";
        String s5 = "我的剑比什么都重要，除了美酒";
        String s6 = "吾之荣耀，离别已久";
        String s7 = "御剑于心，且听风吟";
        String s8 = "回首往昔，更进一步";
        String s9 = "死亡而已，没什么大不了的";
        String s10 = "正义？好一个冠冕堂皇之词";
        String s11 = "长路漫漫，唯剑作伴";
        String s12 = "荣耀存于心，而非留于形";
        String s13 = "还是别出招了，反正是我赢";
        String s14 = "无罪之人，方可安睡";

        class MyThread extends Thread {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    int R = (int) (Math.random() * 256);
                    int G = (int) (Math.random() * 256);
                    int B = (int) (Math.random() * 256);
                    panel.setBackground(new Color(R, G, B));

                    int str = (int) (Math.random() * 14 + 1);
                    switch (str) {
                        case 1:
                            label.setText(s1);
                            break;
                        case 2:
                            label.setText(s2);
                            break;
                        case 3:
                            label.setText(s3);
                            break;
                        case 4:
                            label.setText(s4);
                            break;
                        case 5:
                            label.setText(s5);
                            break;
                        case 6:
                            label.setText(s6);
                            break;
                        case 7:
                            label.setText(s7);
                            break;
                        case 8:
                            label.setText(s8);
                            break;
                        case 9:
                            label.setText(s9);
                            break;
                        case 10:
                            label.setText(s10);
                            break;
                        case 11:
                            label.setText(s11);
                            break;
                        case 12:
                            label.setText(s12);
                            break;
                        case 13:
                            label.setText(s13);
                            break;
                        case 14:
                            label.setText(s14);
                            break;
                    }
                }
            }
        }

        new MyThread().start();
    }
}
